// JavaScript Document

//detailed
/*鼠标滑过分享到时*/
$(document).ready(function(){
	$("#center_share ul").css("opacity",0);
	$("#center_share").hover(function(){
		$("#center_share ul").animate({opacity:1,left:"78px"},200);
		$("#center_share a").addClass("bg")
		$("#center_share ul li a").removeClass("bg")
		},function(){$("#center_share ul").animate({opacity:0,left:"0"},200);
		$("#center_share a").removeClass("bg")
			});

	$(".detail_left ul").find("li").hover(function(){
		$(this).addClass('tb-selected');
		$(this).siblings().removeClass('tb-selected');
		img_src = $(this).find('img').attr('src');
		$(".jqzoom").find('img').attr('src', img_src);
	})

	/*放大镜及小图*/
	$(".jqzoom").jqueryzoom({
	    xzoom:420,
	    yzoom:420,
	    offset:10,
	    position:"right",
	    preload:1,
	    lens:1
	});
});
/*同类热销排行*/
$(function(){
    $(".hotRankList li").hover(function(){
        $(this).find(".rank_box").show().end().siblings("li").find(".rank_box").hide();
    },function(){})

});

/*鼠标滑过Meclub会员特权*/
$(".center_collect_help").hover(function(){

    $(this).find(".center_collect_pop").fadeIn();

},function(){
    setTimeout(function(){
        $(".center_collect_pop").fadeOut();
    },500);
});
/*新品推荐及明星产品切换*/
$(".newStarPro_nav li").hover(function(){
    var index=$(".newStarPro_nav li").index(this);
    $(this).addClass("current").siblings("li").removeClass("current");
    $(this).parents(".newStarPro").find(".newStarPro_item:eq("+index+")").show().siblings(".newStarPro_item").hide();
},function(){});
/*他们购买了滚动*/
var is_right =false;
var page=1;
var i=5;
var height=$('#other_buylist').height();
var len=$('#other_buy').find('li').length;
var page_count=Math.ceil(len/i);
$contain=$('#other_buylist');
var timer;
turn();
function turn(){
    var rolling=function(){if(!$('#other_buy').is(':animated')){
        if(!is_right){
            $('#other_buy').animate({'top':'-='+height+'px'},'slow');
            page++;
            if(page_count <= page){
                is_right=true;
            }
        }else{
            $('#other_buy').css({'top':'0px'});
            page=1;
            is_right=false;
        }

    }
    }
    timer=setInterval(rolling,3000)
    $contain.hover(function(){
        clearInterval(timer);
    },function(){
        timer=setInterval(rolling,3000)
    })
}
/*推荐搭配切换*/
$(".recommend_collocation_title li ").hover(function(){
    var Rindex=$(this).index();
    alert(1111);
    $(this).addClass("current").siblings("li").removeClass("current");
    $(this).parents(".recommend_collocation").find(".recommend_collocation_con:eq("+Rindex+") ").show().siblings(".recommend_collocation_con").hide();

})

/*详情页fixed导航*/
jQuery(window).scroll(function(){if(jQuery(window).scrollTop() >= jQuery('#deal_desc').offset().top){

    jQuery('.fixed').attr('id','fixed');

}else{jQuery('.fixed').attr('id',false); }

});
/*鼠标点击fixed导航*/
$(".inLeft_btn a").click(function(){
    $(this).addClass("current").parent("li").siblings("li").find("a").removeClass("current");
})
/*优势下切换*/
$(document).ready(function(){
    $(".inLeft_tabnav").hide();
    $("#inLeft_tabnav_0").show();
    })
function tabs(divId){
    $("#inLeft_tabnav_"+divId).show().siblings().hide();
    }

/*证书无缝滚动-*/

   var Marquee = function(id){
    try{document.execCommand("BackgroundImageCache", false, true);}catch(e){};
    var container = document.getElementById(id),
    original = container.getElementsByTagName("dt")[0],
    clone = container.getElementsByTagName("dd")[0],
    speed = arguments[1] || 10;
    clone.innerHTML=original.innerHTML;
    var rolling = function(){
        if(container.scrollLeft == clone.offsetLeft){
        container.scrollLeft = 0;
        }else{
        container.scrollLeft++;
        }
    }
    var timer = setInterval(rolling,speed);//设置定时器
    container.onmouseover=function() {clearInterval(timer);}//鼠标移到marquee上时，清除定时器，停止滚动
    container.onmouseout=function() {timer=setInterval(rolling,speed);}//鼠标移开时重设定时器
}
window.onload = function(){
    Marquee("marquee");
 }
/**评论展开**/
$(".comment_list_down").click( 
		function(){
			//获取高
			var $list_box_p = $(this).siblings("p");
			if( $list_box_p.css('height') == '24px'){
					$list_box_p.css("height","auto");
					$(this).addClass("comment_list_up")
			}else{
					$list_box_p.css("height","24px");
					$(this).removeClass("comment_list_up")
			}
		}
	)
/**评论更多*/
$("#comments-more").click(function(){
	var page = parseInt($("#comments-more").attr('page'));
	var pagecount = $("#comments-more").attr('pagecount');
	page = page+1;
	$(this).attr('page',page);
	var count = 10*page;
	
	$(".comment_list:lt("+count+")").css('display','block');
	if(page >= pagecount){
		$(this).css('display','none');	
	}
	if(page > 5){
		$("#comments-id").attr('href',WEB_ROOT +"/comments/");
		$(this).unbind('click');	
	}
	});

/**加入购物车数量控制**/
	jQuery('#decreasenum').click(function(){
		  
		  var oldnum = parseInt(jQuery('#quantity-id').val());
		  ////减
		  if(oldnum<=1){
			  return;
		  }
		  var newnum = oldnum - 1;
		  jQuery('#quantity-id').val(newnum);
	  });
	  jQuery('#increasenum').click(function(){
		  var per_num = parseInt(jQuery('#pernum').val());
		  var oldnum = parseInt(jQuery('#quantity-id').val());
		  if(oldnum>=per_num && per_num){
			  return;
		  }
		  if(oldnum > 9){
			  alert('最大数量不超过10个');
			  return;
		  }
		  var newnum = oldnum + 1;
		  jQuery('#quantity-id').val(newnum);
	  });




